Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor | CAKK-61 | DIP 위반 문제 해결 #201

Merged
merged 2 commits into from
Aug 31, 2024
Merged

Conversation

lcomment
Copy link
Collaborator

Issue Number

CAKK-61

Description

지난 PR에서 추상화 및 템플릿 콜백 패턴을 적용했으나 API 모듈에서 일부 Extractor와 Sender에 대해서 하위 모듈인 external 모듈에 의존하는, DIP 위반 사례가 있었습니다. 여러 방법을 고민한 끝에 API 모듈에 의존성을 추가 시키고, Extractor와 Sender 의존성 주입에 대한 책임을 API 모듈에 두면서 DIP 문제를 해결했습니다.

Core Code

@Configuration
public class MessageTemplateConfig {

	private final JavaMailSender javaMailSender;
	private final SlackApi slackApi;

	private final String senderEmail;
	private final Boolean isEnable;

	public MessageTemplateConfig(
		JavaMailSender javaMailSender,
		SlackApi slackApi,
		@Value("${spring.mail.username}")
		String senderEmail,
		@Value("${slack.webhook.is-enable}")
		Boolean isEnable
	) {
		this.javaMailSender = javaMailSender;
		this.senderEmail = senderEmail;
		this.isEnable = isEnable;
		this.slackApi = slackApi;
	}

	@Bean
	public MessageTemplate certificationTemplate() {
		return new MessageTemplate();
	}

	@Bean
	public MessageExtractor certificationMessageExtractor() {
		return new CertificationSlackMessageExtractor();
	}

	@Bean
	public MessageExtractor errorAlertMessageExtractor() {
		return new ErrorAlertSlackMessageExtractor();
	}

	@Bean
	public MessageExtractor verificationCodeMimeMessageExtractor() {
		return new VerificationCodeMimeMessageExtractor(javaMailSender, senderEmail);
	}

	@Bean
	public MessageSender emailMessageSender() {
		return new EmailMessageSender(javaMailSender);
	}

	@Bean
	public MessageSender slackMessageSender() {
		return new SlackMessageSender(slackApi, isEnable);
	}
}

etc

@lcomment lcomment self-assigned this Aug 30, 2024
@lcomment lcomment requested a review from YongsHub August 30, 2024 15:48
@lcomment lcomment added the refactor 비즈니스 변경 없는 수정 label Aug 30, 2024
Copy link

Test Results

 40 files  ±0   40 suites  ±0   27s ⏱️ -1s
215 tests ±0  215 ✅ ±0  0 💤 ±0  0 ❌ ±0 
216 runs  ±0  216 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit c42acc1. ± Comparison against base commit 0346e96.

Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #201      +/-   ##
=============================================
+ Coverage      92.64%   92.80%   +0.16%     
- Complexity       329      333       +4     
=============================================
  Files            109      109              
  Lines            965      973       +8     
  Branches          34       34              
=============================================
+ Hits             894      903       +9     
  Misses            53       53              
+ Partials          18       17       -1     
Files with missing lines Coverage Δ Complexity Δ
...ava/com/cakk/api/config/MessageTemplateConfig.java 100.00% <100.00%> (ø) 7.00 <4.00> (+3.00)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0346e96...c42acc1. Read the comment docs.

@lcomment lcomment merged commit 1aa3922 into develop Aug 31, 2024
3 checks passed
@lcomment lcomment deleted the refactor/CAKK-61 branch August 31, 2024 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor 비즈니스 변경 없는 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants